/*============================================================================
  File:     CleanUp.sql

  Summary:  Delete default alerts in Microsoft SQL Server 2005.

  Date:     June 15, 2005
------------------------------------------------------------------------------
  This file is part of the Microsoft SQL Server Code Samples.

  Copyright (C) Microsoft Corporation.  All rights reserved.

  This source code is intended only as a supplement to Microsoft
  Development Tools and/or on-line documentation.  See these other
  materials for detailed information regarding Microsoft code samples.

  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  PARTICULAR PURPOSE.
============================================================================*/

PRINT ''
PRINT 'Removing default alerts...'
GO

IF EXISTS (SELECT *
                FROM msdb.dbo.sysalerts
                WHERE (name = N'Sample: Full msdb log'))
	EXECUTE msdb.dbo.sp_delete_alert 
		@name = N'Sample: Full msdb log';
GO

IF EXISTS (SELECT *
                FROM msdb.dbo.sysalerts
                WHERE (name = N'Sample: Full tempdb'))
	EXECUTE msdb.dbo.sp_delete_alert 
		@name = N'Sample: Full tempdb';
GO

IF EXISTS (SELECT *
                FROM msdb.dbo.sysalerts
                WHERE (name = N'Sample: Sev. 19 Errors'))
	EXECUTE msdb.dbo.sp_delete_alert 
		@name = N'Sample: Sev. 19 Errors';
GO

IF EXISTS (SELECT *
                FROM msdb.dbo.sysalerts
                WHERE (name = N'Sample: Sev. 20 Errors'))
	EXECUTE msdb.dbo.sp_delete_alert 
		@name = N'Sample: Sev. 20 Errors';
GO

IF EXISTS (SELECT *
                FROM msdb.dbo.sysalerts
                WHERE (name = N'Sample: Sev. 21 Errors'))
	EXECUTE msdb.dbo.sp_delete_alert 
		@name = N'Sample: Sev. 21 Errors';
GO

IF EXISTS (SELECT *
                FROM msdb.dbo.sysalerts
                WHERE (name = N'Sample: Sev. 22 Errors'))
	EXECUTE msdb.dbo.sp_delete_alert 
		@name = N'Sample: Sev. 22 Errors';
GO

IF EXISTS (SELECT *
                FROM msdb.dbo.sysalerts
                WHERE name = N'Sample: Sev. 23 Errors')
	EXECUTE msdb.dbo.sp_delete_alert 
		@name = N'Sample: Sev. 23 Errors';
GO

IF EXISTS (SELECT *
                FROM msdb.dbo.sysalerts
                WHERE (name = N'Sample: Sev. 24 Errors'))
	EXECUTE msdb.dbo.sp_delete_alert 
		@name = N'Sample: Sev. 24 Errors';
GO

IF EXISTS (SELECT *
                FROM msdb.dbo.sysalerts
                WHERE (name = N'Sample: Sev. 25 Errors'))
	EXECUTE msdb.dbo.sp_delete_alert 
		@name = N'Sample: Sev. 25 Errors';
GO

PRINT ''
PRINT 'Completed.'
GO

-- List the default alerts
-- EXECUTE msdb.dbo.sp_help_alert;
GO
